﻿/*
Digraph (library for building, traversal, comparison and saving of directed
graph).

Copyright (C) 2014 Dmitry Merzagitovich Arslanov

This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option) any
later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*/

// How to get minimum path between two vertices in digraph.
namespace Sample8
{
    using System;

    using Vertex = Digraph.Vertex<string, string>;
    using Arc = Digraph.Arc<string, string>;
    using Builder = Digraph.Builder<string, string>;
    using Path = Digraph.Path<string, string>;

    public static class App
    {
        public static void Main()
        {
            // Build digraph with minimum path a1-a2 between v1 and v3.
            Builder b = new Builder();
            Vertex v1 = b.NewVertex("v1");
            Vertex v2 = b.NewVertex("v2");
            Vertex v3 = b.NewVertex("v3");
            Vertex v4 = b.NewVertex("v4");
            Vertex v5 = b.NewVertex("v5");
            b.NewArc(v1, v2, "a1");
            b.NewArc(v2, v3, "a2");
            b.NewArc(v2, v4, "a3");
            b.NewArc(v4, v2, "a4");
            // Length of each arc equals 1.0.
            Path path = b.Digraph.GetMinimumPath(v1, v3, arc => 1.0);
            foreach (Arc arc in path)
            {
                Console.WriteLine(arc.Content);
            }
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
    }
}

#region Program output is shown below in comments
/*
a1
a2
Press any key to exit...
*/
#endregion
